home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Supervisor's Toolkit
/
Network Supervisor's Toolkit.iso
/
tools
/
lu62
/
debug
/
ini.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-10
|
5KB
|
199 lines
/*
* CopyRight 1995. Nicholas Poljakov all rights reserved.
*/
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <stdlib.h>
#include <fcntl.h>
#include <io.h>
#include <dos.h>
#include <conio.h>
#include <sys\types.h>
#include <sys\stat.h>
#define MAX_FRAME 31
#define F1 59
#define F2 60
#define F3 61
#define F4 62
#define F5 63
#define F6 64
#define F7 65
#define F8 66
#define F9 67
#define F10 68
extern char *vid_mem;
extern char *sv;
extern int fd_ini;
extern struct APL_PARM{
int status; /* 0-start aplmain,1-start transaction,2-dos shell */
char p[80]; /* string for system(p) */
char args[64];/* string of arguments */
int rc; /* aplmain return code */
char dir[60];/* directory name for aplmain */
int drlen; /* directory name length */
void *tpe; /* entry of exit program */
char pgm_state;
}*p_aparm;
extern short cur_ln;
extern struct menu_frame {
int startx, endx, starty, endy;
unsigned char *p;
char **menu;
char *keys;
int border;
int count;
unsigned char attrib;
int active;
int curx, cury;
char *header;
unsigned char shd;
} frame[MAX_FRAME];
char lu_name[9];
char mode_name[9];
int p_lu_num; /* number of LU - partners */
struct lctl {
char lu_name[8];
char mode_name[8];
int lu_num;
short cur_ln;
} *lctl;
struct part { /* partner structure */
char plu[8] ; /* str plu_name */
int psl; /* str plu_s_limit */
char mode_name[8] ; /* str mode_name */
int max_ru_size; /* str ru_h_size */
int pacing; /* str = */
unsigned char lu_type;
} pstr[4];
#define L_SIZ sizeof(struct lctl) + (sizeof(struct part) * 4)
#define L_PSTR sizeof(struct part) * 4
int set0(char *p, int lt);
set_ini()
{
int i;
unsigned ch;
char buff[L_SIZ];
char *p;
char full[80];
strcpy(full,p_aparm -> dir);
full[p_aparm -> drlen] = 0x5c;
full[p_aparm -> drlen+1] = 0x00;
strcat(full,"apl.ini");
if ((fd_ini = open(full, (O_RDWR | O_BINARY))) != -1) {
if ((i = read(fd_ini, buff, L_SIZ)) < 0) {
return 0;
}
if (i < L_SIZ) {
return 0;
}
lctl = &buff;
memcpy(lu_name, lctl -> lu_name, 8);
memcpy(mode_name, lctl -> mode_name, 8);
p_lu_num = lctl -> lu_num;
cur_ln = lctl -> cur_ln;
p = &buff;
p += sizeof(struct lctl);
memcpy(&pstr, p, L_PSTR);
if ( p_aparm -> rc != 0 )
return 0;
showp(0);
window(23);
window_xy(23, 0, 3);
frame[23].attrib = 0x7f;
window_puts(23, "Are you sure you want this configuration ? [Y]");
frame[23].attrib = 0x70;
Retry:
window_xy(23, 0, 47);
ch = getch();
if (ch == 0) {
ch = getch();
if (ch == F1) {
help("1 ");
}
}
ch &= 0x00ff;
if ((ch == 'y')||(ch == 'Y')) {
goto IniExit;
}
if ((ch == 'n')||(ch == 'N')) {
p_lu_num = 0;
lu_name[0] = 0x00;
mode_name[0] = 0x00;
set0(&pstr, L_PSTR);
p_lu_num = 0;
goto IniExit;
}
goto Retry;
}
else {
fd_ini = creat(full, S_IWRITE);
return 0;
}
IniExit:
deactivate(23);
deactivate(22);
return 0;
}
save_ini()
{
int i;
char buff[L_SIZ];
char *p;
if (fd_ini != -1) {
i = lseek(fd_ini, (long)0,SEEK_SET);
lctl = &buff;
memcpy(lctl -> lu_name, lu_name, 8);
memcpy(lctl -> mode_name, mode_name, 8);
lctl -> lu_num = p_lu_num;
lctl -> cur_ln = cur_ln;
p = &buff;
p += sizeof(struct lctl);
memcpy(p, &pstr, L_PSTR);
write(fd_ini, &buff, L_SIZ);
close(fd_ini);
}
return 0;
}
set0(p, lt)
char *p;
int lt;
{
char _near *tp1;
char _near *tp2;
unsigned int l;
l = lt;
tp1 = FP_SEG( p );
tp2 = FP_OFF( p );
_asm
{
push di
mov ax, word ptr tp1[0]
mov es, ax
mov di, word ptr tp2[0]
mov cx, word ptr l[0]
mov al, 0
cld
rep stosb
pop di
}
}